<?php
require_once 'PaymentView.php';
	class PaymentManager{
	
		public function validate($snum,$term,$periodCovered,$receiptNo,$dormFee,$applianceFee,$transFee,$datePaid,$remarks,$duration){
		
			if(is_numeric($snum)&&is_numeric($receiptNo)&&is_numeric($dormFee)&&($term!=""||$term!=null)&&($periodCovered!=""||$periodCovered!=null)&&($datePaid!=""||$datePaid!=null)){
					return true;
				}else{
					return false;
			}
		}
		
		public function insertPayment($snum,$term,$periodCovered,$receiptNo,$dormFee,$applianceFee,$transFee,$datePaid,$remarks,$duration){	
			$conn=oci_connect("naiad","1234","localhost/XE");
			if(!$conn){
				$err[] = "Connection error!". var_dump(oci_error());
				echo '<scPaymript> alert("'.$err.'") </script>';
				die();
				oci_close($conn);
			}
			else{
				$stpay = oci_parse($conn,"insert into payment(studentno,term,periodcovered,receiptno,dormfee,appliancefee,transfee,datepaid,remarks,duration) values(:studentno,:term,:periodcovered,:receiptno,:dormfee,:appliancefee,:transfee,:datepaid,:remarks,:duration)");
				oci_bind_by_name($stpay, ":studentno", $snum);
				oci_bind_by_name($stpay, ":term", $term);
				oci_bind_by_name($stpay, ":periodcovered", $periodCovered);
				oci_bind_by_name($stpay, ":receiptno", $receiptNo);
				oci_bind_by_name($stpay, ":dormfee", $dormFee);
				oci_bind_by_name($stpay, ":appliancefee", $applianceFee);
				oci_bind_by_name($stpay, ":transfee", $transFee);
				oci_bind_by_name($stpay, ":datepaid", $datePaid);
				oci_bind_by_name($stpay, ":remarks", $remarks);
				oci_bind_by_name($stpay, ":duration", $duration);

				$exec1 = oci_execute($stpay);
				if($exec1==true){
					return 1;
				}
				oci_commit($conn);
				//oci_free_statement($stid);
				oci_close($conn);
			}	
		}		
	}//class
?>
